home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.5 Applications 2002 November / SGI IRIX 6.5 Applications 2002 November.iso / dist / sgi_apache.idb / var / sgi_apache / server / include / httpd.h.z / httpd.h
Encoding:
C/C++ Source or Header  |  2002-06-27  |  45.7 KB  |  1,272 lines

  1. /* ====================================================================
  2.  * The Apache Software License, Version 1.1
  3.  *
  4.  * Copyright (c) 2000-2002 The Apache Software Foundation.  All rights
  5.  * reserved.
  6.  *
  7.  * Redistribution and use in source and binary forms, with or without
  8.  * modification, are permitted provided that the following conditions
  9.  * are met:
  10.  *
  11.  * 1. Redistributions of source code must retain the above copyright
  12.  *    notice, this list of conditions and the following disclaimer.
  13.  *
  14.  * 2. Redistributions in binary form must reproduce the above copyright
  15.  *    notice, this list of conditions and the following disclaimer in
  16.  *    the documentation and/or other materials provided with the
  17.  *    distribution.
  18.  *
  19.  * 3. The end-user documentation included with the redistribution,
  20.  *    if any, must include the following acknowledgment:
  21.  *       "This product includes software developed by the
  22.  *        Apache Software Foundation (http://www.apache.org/)."
  23.  *    Alternately, this acknowledgment may appear in the software itself,
  24.  *    if and wherever such third-party acknowledgments normally appear.
  25.  *
  26.  * 4. The names "Apache" and "Apache Software Foundation" must
  27.  *    not be used to endorse or promote products derived from this
  28.  *    software without prior written permission. For written
  29.  *    permission, please contact apache@apache.org.
  30.  *
  31.  * 5. Products derived from this software may not be called "Apache",
  32.  *    nor may "Apache" appear in their name, without prior written
  33.  *    permission of the Apache Software Foundation.
  34.  *
  35.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  36.  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  37.  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  38.  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  39.  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  40.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  41.  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  42.  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  43.  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  44.  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  45.  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  46.  * SUCH DAMAGE.
  47.  * ====================================================================
  48.  *
  49.  * This software consists of voluntary contributions made by many
  50.  * individuals on behalf of the Apache Software Foundation.  For more
  51.  * information on the Apache Software Foundation, please see
  52.  * <http://www.apache.org/>.
  53.  *
  54.  * Portions of this software are based upon public domain software
  55.  * originally written at the National Center for Supercomputing Applications,
  56.  * University of Illinois, Urbana-Champaign.
  57.  */
  58.  
  59. #ifndef APACHE_HTTPD_H
  60. #define APACHE_HTTPD_H
  61.  
  62. #ifdef __cplusplus
  63. extern "C" {
  64. #endif
  65.  
  66. /*
  67.  * httpd.h: header for simple (ha! not anymore) http daemon
  68.  */
  69.  
  70. /* Headers in which EVERYONE has an interest... */
  71.  
  72. #include "ap_config.h"
  73. #ifdef EAPI
  74. #include "ap_mm.h"
  75. #endif
  76. #include "ap_alloc.h"
  77. /*
  78.  * Include the Extended API headers.
  79.  * Don't move the position. It has to be after ap_alloc.h because it uses the
  80.  * pool stuff but before buff.h because the buffer stuff uses the EAPI, too. 
  81.  */
  82. #ifdef EAPI
  83. #include "ap_hook.h"
  84. #include "ap_ctx.h"
  85. #endif /* EAPI */
  86. #include "buff.h"
  87. #include "ap.h"
  88.  
  89. /* ----------------------------- config dir ------------------------------ */
  90.  
  91. /* Define this to be the default server home dir. Most things later in this
  92.  * file with a relative pathname will have this added.
  93.  */
  94. #ifndef HTTPD_ROOT
  95. #ifdef OS2
  96. /* Set default for OS/2 file system */
  97. #define HTTPD_ROOT "/os2httpd"
  98. #elif defined(WIN32)
  99. /* Set default for Windows file system */
  100. #define HTTPD_ROOT "/apache"
  101. #elif defined(BEOS) || defined(BONE)
  102. #define HTTPD_ROOT "/boot/home/apache"
  103. #elif defined(NETWARE)
  104. #define HTTPD_ROOT "sys:/apache"
  105. #else
  106. #define HTTPD_ROOT "/usr/local/apache"
  107. #endif
  108. #endif /* HTTPD_ROOT */
  109.  
  110. /* Default location of documents.  Can be overridden by the DocumentRoot
  111.  * directive.
  112.  */
  113. #ifndef DOCUMENT_LOCATION
  114. #ifdef OS2
  115. /* Set default for OS/2 file system */
  116. #define DOCUMENT_LOCATION  HTTPD_ROOT "/docs"
  117. #else
  118. #define DOCUMENT_LOCATION  HTTPD_ROOT "/htdocs"
  119. #endif
  120. #endif /* DOCUMENT_LOCATION */
  121.  
  122. /* Max. number of dynamically loaded modules */
  123. #ifndef DYNAMIC_MODULE_LIMIT
  124. #define DYNAMIC_MODULE_LIMIT 64
  125. #endif
  126.  
  127. /* Default administrator's address */
  128. #define DEFAULT_ADMIN "[no address given]"
  129.  
  130. /* The target name of the installed Apache */
  131. #ifndef TARGET
  132. #define TARGET "httpd"
  133. #endif
  134.  
  135. /* 
  136.  * --------- You shouldn't have to edit anything below this line ----------
  137.  *
  138.  * Any modifications to any defaults not defined above should be done in the 
  139.  * respective config. file. 
  140.  *
  141.  */
  142.  
  143.  
  144. /* -- Internal representation for a HTTP protocol number, e.g., HTTP/1.1 -- */
  145.  
  146. #define HTTP_VERSION(major,minor) (1000*(major)+(minor))
  147. #define HTTP_VERSION_MAJOR(number) ((number)/1000)
  148. #define HTTP_VERSION_MINOR(number) ((number)%1000)
  149.  
  150.  
  151. /* -------------- Port number for server running standalone --------------- */
  152.  
  153. #define DEFAULT_HTTP_PORT    80
  154. #define DEFAULT_HTTPS_PORT    443
  155. #define ap_is_default_port(port,r)    ((port) == ap_default_port(r))
  156. #ifdef EAPI
  157. #define ap_http_method(r)   (((r)->ctx != NULL && ap_ctx_get((r)->ctx, "ap::http::method") != NULL) ? ((char *)ap_ctx_get((r)->ctx, "ap::http::method")) : "http")
  158. #define ap_default_port(r)  (((r)->ctx != NULL && ap_ctx_get((r)->ctx, "ap::default::port") != NULL) ? atoi((char *)ap_ctx_get((r)->ctx, "ap::default::port")) : DEFAULT_HTTP_PORT)
  159. #else /* EAPI */
  160. #ifdef NETWARE
  161. #define ap_http_method(r) ap_os_http_method(r)
  162. #else
  163. #define ap_http_method(r)    "http"
  164. #endif
  165. #define ap_default_port(r)    DEFAULT_HTTP_PORT
  166. #endif /* EAPI */
  167.  
  168. /* --------- Default user name and group name running standalone ---------- */
  169. /* --- These may be specified as numbers by placing a # before a number --- */
  170.  
  171. #ifndef DEFAULT_USER
  172. #define DEFAULT_USER "#-1"
  173. #endif
  174. #ifndef DEFAULT_GROUP
  175. #define DEFAULT_GROUP "#-1"
  176. #endif
  177.  
  178. #ifndef DEFAULT_ERRORLOG
  179. #if defined(OS2) || defined(WIN32)
  180. #define DEFAULT_ERRORLOG "logs/error.log"
  181. #else
  182. #define DEFAULT_ERRORLOG "logs/error_log"
  183. #endif
  184. #endif /* DEFAULT_ERRORLOG */
  185.  
  186. #ifndef DEFAULT_PIDLOG
  187. #define DEFAULT_PIDLOG "logs/httpd.pid"
  188. #endif
  189. #ifndef DEFAULT_SCOREBOARD
  190. #define DEFAULT_SCOREBOARD "logs/apache_runtime_status"
  191. #endif
  192. #ifndef DEFAULT_LOCKFILE
  193. #define DEFAULT_LOCKFILE "logs/accept.lock"
  194. #endif
  195.  
  196. /* Define this to be what your HTML directory content files are called */
  197. #ifndef DEFAULT_INDEX
  198. #define DEFAULT_INDEX "index.html"
  199. #endif
  200.  
  201. /* Define this to 1 if you want fancy indexing, 0 otherwise */
  202. #ifndef DEFAULT_INDEXING
  203. #define DEFAULT_INDEXING 0
  204. #endif
  205.  
  206. /* Define this to be what type you'd like returned for files with unknown */
  207. /* suffixes.  MUST be all lower case. */
  208. #ifndef DEFAULT_CONTENT_TYPE
  209. #define DEFAULT_CONTENT_TYPE "text/plain"
  210. #endif
  211.  
  212. /* Define this to be what your per-directory security files are called */
  213. #ifndef DEFAULT_ACCESS_FNAME
  214. #ifdef OS2
  215. /* Set default for OS/2 file system */
  216. #define DEFAULT_ACCESS_FNAME "htaccess"
  217. #else
  218. #define DEFAULT_ACCESS_FNAME ".htaccess"
  219. #endif
  220. #endif /* DEFAULT_ACCESS_FNAME */
  221.  
  222. /* The name of the server config file */
  223. #ifndef SERVER_CONFIG_FILE
  224. #define SERVER_CONFIG_FILE "conf/httpd.conf"
  225. #endif
  226.  
  227. /* The name of the document config file */
  228. #ifndef RESOURCE_CONFIG_FILE
  229. #define RESOURCE_CONFIG_FILE "conf/srm.conf"
  230. #endif
  231.  
  232. /* The name of the MIME types file */
  233. #ifndef TYPES_CONFIG_FILE
  234. #define TYPES_CONFIG_FILE "conf/mime.types"
  235. #endif
  236.  
  237. /* The name of the access file */
  238. #ifndef ACCESS_CONFIG_FILE
  239. #define ACCESS_CONFIG_FILE "conf/access.conf"
  240. #endif
  241.  
  242. /* Whether we should enable rfc1413 identity checking */
  243. #ifndef DEFAULT_RFC1413
  244. #define DEFAULT_RFC1413 0
  245. #endif
  246. /* The default directory in user's home dir */
  247. #ifndef DEFAULT_USER_DIR
  248. #define DEFAULT_USER_DIR "public_html"
  249. #endif
  250.  
  251. /* The default path for CGI scripts if none is currently set */
  252. #ifndef DEFAULT_PATH
  253. #define DEFAULT_PATH "/bin:/usr/bin:/usr/ucb:/usr/bsd:/usr/local/bin"
  254. #endif
  255.  
  256. /* The path to the shell interpreter, for parsed docs */
  257. #ifndef SHELL_PATH
  258. #if defined(OS2) || defined(WIN32)
  259. /* Set default for OS/2 and Windows file system */
  260. #define SHELL_PATH "CMD.EXE"
  261. #else
  262. #define SHELL_PATH "/bin/sh"
  263. #endif
  264. #endif /* SHELL_PATH */
  265.  
  266. /* The path to the suExec wrapper, can be overridden in Configuration */
  267. #ifndef SUEXEC_BIN
  268. #define SUEXEC_BIN  HTTPD_ROOT "/bin/suexec"
  269. #endif
  270.  
  271. /* The default string lengths */
  272. #define MAX_STRING_LEN HUGE_STRING_LEN
  273. #define HUGE_STRING_LEN 8192
  274.  
  275. /* The timeout for waiting for messages */
  276. #ifndef DEFAULT_TIMEOUT
  277. #define DEFAULT_TIMEOUT 300
  278. #endif
  279.  
  280. /* The timeout for waiting for keepalive timeout until next request */
  281. #ifndef DEFAULT_KEEPALIVE_TIMEOUT
  282. #define DEFAULT_KEEPALIVE_TIMEOUT 15
  283. #endif
  284.  
  285. /* The number of requests to entertain per connection */
  286. #ifndef DEFAULT_KEEPALIVE
  287. #define DEFAULT_KEEPALIVE 100
  288. #endif
  289.  
  290. /* The size of the server's internal read-write buffers */
  291. #define IOBUFSIZE 8192
  292.  
  293. /* Number of servers to spawn off by default --- also, if fewer than
  294.  * this free when the caretaker checks, it will spawn more.
  295.  */
  296. #ifndef DEFAULT_START_DAEMON
  297. #define DEFAULT_START_DAEMON 5
  298. #endif
  299.  
  300. /* Maximum number of *free* server processes --- more than this, and
  301.  * they will die off.
  302.  */
  303.  
  304. #ifndef DEFAULT_MAX_FREE_DAEMON
  305. #define DEFAULT_MAX_FREE_DAEMON 10
  306. #endif
  307.  
  308. /* Minimum --- fewer than this, and more will be created */
  309.  
  310. #ifndef DEFAULT_MIN_FREE_DAEMON
  311. #define DEFAULT_MIN_FREE_DAEMON 5
  312. #endif
  313.  
  314. /* Limit on the total --- clients will be locked out if more servers than
  315.  * this are needed.  It is intended solely to keep the server from crashing
  316.  * when things get out of hand.
  317.  *
  318.  * We keep a hard maximum number of servers, for two reasons --- first off,
  319.  * in case something goes seriously wrong, we want to stop the fork bomb
  320.  * short of actually crashing the machine we're running on by filling some
  321.  * kernel table.  Secondly, it keeps the size of the scoreboard file small
  322.  * enough that we can read the whole thing without worrying too much about
  323.  * the overhead.
  324.  */
  325. #ifndef HARD_SERVER_LIMIT
  326. #ifdef WIN32
  327. #define HARD_SERVER_LIMIT 1024
  328. #elif defined(NETWARE)
  329. #define HARD_SERVER_LIMIT 2048
  330. #else
  331. #define HARD_SERVER_LIMIT 256
  332. #endif
  333. #endif
  334.  
  335. /*
  336.  * Special Apache error codes. These are basically used
  337.  *  in http_main.c so we can keep track of various errors.
  338.  *
  339.  *   APEXIT_OK:
  340.  *     A normal exit
  341.  *   APEXIT_INIT:
  342.  *     A fatal error arising during the server's init sequence
  343.  *   APEXIT_CHILDINIT:
  344.  *     The child died during it's init sequence
  345.  *   APEXIT_CHILDFATAL:
  346.  *     A fatal error, resulting in the whole server aborting.
  347.  *     If a child exits with this error, the parent process
  348.  *     considers this a server-wide fatal error and aborts.
  349.  *                 
  350.  */
  351. #define APEXIT_OK        0x0
  352. #define APEXIT_INIT        0x2
  353. #define APEXIT_CHILDINIT    0x3
  354. #define APEXIT_CHILDFATAL    0xf
  355.  
  356. /*
  357.  * (Unix, OS/2 only)
  358.  * Interval, in microseconds, between scoreboard maintenance.  During
  359.  * each scoreboard maintenance cycle the parent decides if it needs to
  360.  * spawn a new child (to meet MinSpareServers requirements), or kill off
  361.  * a child (to meet MaxSpareServers requirements).  It will only spawn or
  362.  * kill one child per cycle.  Setting this too low will chew cpu.  The
  363.  * default is probably sufficient for everyone.  But some people may want
  364.  * to raise this on servers which aren't dedicated to httpd and where they
  365.  * don't like the httpd waking up each second to see what's going on.
  366.  */
  367. #ifndef SCOREBOARD_MAINTENANCE_INTERVAL
  368. #define SCOREBOARD_MAINTENANCE_INTERVAL 1000000
  369. #endif
  370.  
  371. /*
  372.  * Unix only:
  373.  * Path to Shared Memory Files 
  374.  */
  375. #ifdef EAPI
  376. #ifndef EAPI_MM_CORE_PATH
  377. #define EAPI_MM_CORE_PATH "logs/mm"
  378. #endif
  379. #ifndef EAPI_MM_CORE_MAXSIZE
  380. #define EAPI_MM_CORE_MAXSIZE 1024*1024*1 /* max. 1MB */
  381. #endif
  382. #endif
  383.  
  384. /* Number of requests to try to handle in a single process.  If <= 0,
  385.  * the children don't die off.  That's the default here, since I'm still
  386.  * interested in finding and stanching leaks.
  387.  */
  388.  
  389. #ifndef DEFAULT_MAX_REQUESTS_PER_CHILD
  390. #define DEFAULT_MAX_REQUESTS_PER_CHILD 0
  391. #endif
  392.  
  393. #ifndef DEFAULT_THREADS_PER_CHILD
  394. #define DEFAULT_THREADS_PER_CHILD 50
  395. #endif
  396. #ifndef DEFAULT_EXCESS_REQUESTS_PER_CHILD
  397. #define DEFAULT_EXCESS_REQUESTS_PER_CHILD 0
  398. #endif
  399.  
  400. /* The maximum length of the queue of pending connections, as defined
  401.  * by listen(2).  Under some systems, it should be increased if you
  402.  * are experiencing a heavy TCP SYN flood attack.
  403.  *
  404.  * It defaults to 511 instead of 512 because some systems store it 
  405.  * as an 8-bit datatype; 512 truncated to 8-bits is 0, while 511 is 
  406.  * 255 when truncated.
  407.  */
  408.  
  409. #ifndef DEFAULT_LISTENBACKLOG
  410. #define DEFAULT_LISTENBACKLOG 511
  411. #endif
  412.  
  413. /* Limits on the size of various request items.  These limits primarily
  414.  * exist to prevent simple denial-of-service attacks on a server based
  415.  * on misuse of the protocol.  The recommended values will depend on the
  416.  * nature of the server resources -- CGI scripts and database backends
  417.  * might require large values, but most servers could get by with much
  418.  * smaller limits than we use below.  The request message body size can
  419.  * be limited by the per-dir config directive LimitRequestBody.
  420.  *
  421.  * Internal buffer sizes are two bytes more than the DEFAULT_LIMIT_REQUEST_LINE
  422.  * and DEFAULT_LIMIT_REQUEST_FIELDSIZE below, which explains the 8190.
  423.  * These two limits can be lowered (but not raised) by the server config
  424.  * directives LimitRequestLine and LimitRequestFieldsize, respectively.
  425.  *
  426.  * DEFAULT_LIMIT_REQUEST_FIELDS can be modified or disabled (set = 0) by
  427.  * the server config directive LimitRequestFields.
  428.  */
  429. #ifndef DEFAULT_LIMIT_REQUEST_LINE
  430. #define DEFAULT_LIMIT_REQUEST_LINE 8190
  431. #endif /* default limit on bytes in Request-Line (Method+URI+HTTP-version) */
  432. #ifndef DEFAULT_LIMIT_REQUEST_FIELDSIZE
  433. #define DEFAULT_LIMIT_REQUEST_FIELDSIZE 8190
  434. #endif /* default limit on bytes in any one header field  */
  435. #ifndef DEFAULT_LIMIT_REQUEST_FIELDS
  436. #define DEFAULT_LIMIT_REQUEST_FIELDS 100
  437. #endif /* default limit on number of request header fields */
  438.  
  439. /*
  440.  * The default default character set name to add if AddDefaultCharset is 
  441.  * enabled.  Overridden with AddDefaultCharsetName.
  442.  */
  443. #define DEFAULT_ADD_DEFAULT_CHARSET_NAME "iso-8859-1"
  444.  
  445. /*
  446.  * The below defines the base string of the Server: header. Additional
  447.  * tokens can be added via the ap_add_version_component() API call.
  448.  *
  449.  * The tokens are listed in order of their significance for identifying the
  450.  * application.
  451.  *
  452.  * "Product tokens should be short and to the point -- use of them for 
  453.  * advertizing or other non-essential information is explicitly forbidden."
  454.  *
  455.  * Example: "Apache/1.1.0 MrWidget/0.1-alpha" 
  456.  */
  457.  
  458. #define SERVER_BASEVENDOR   "Apache Group"
  459. #define SERVER_BASEPRODUCT  "Apache"
  460. #define SERVER_BASEREVISION "1.3.26"
  461. #define SERVER_BASEVERSION  SERVER_BASEPRODUCT "/" SERVER_BASEREVISION
  462.  
  463. #define SERVER_PRODUCT  SERVER_BASEPRODUCT
  464. #define SERVER_REVISION SERVER_BASEREVISION
  465. #define SERVER_VERSION  SERVER_PRODUCT "/" SERVER_REVISION
  466. enum server_token_type {
  467.     SrvTk_MIN,        /* eg: Apache/1.3.0 */
  468.     SrvTk_OS,        /* eg: Apache/1.3.0 (UNIX) */
  469.     SrvTk_FULL,        /* eg: Apache/1.3.0 (UNIX) PHP/3.0 FooBar/1.2b */
  470.     SrvTk_PRODUCT_ONLY    /* eg: Apache */
  471. };
  472.  
  473. API_EXPORT(const char *) ap_get_server_version(void);
  474. API_EXPORT(void) ap_add_version_component(const char *component);
  475. API_EXPORT(const char *) ap_get_server_built(void);
  476. #ifdef EAPI
  477. API_EXPORT(void) ap_add_config_define(const char *define);
  478. #endif /* EAPI */
  479.  
  480. /* Numeric release version identifier: MMNNFFRBB: major minor fix final beta
  481.  * Always increases along the same track as the source branch.
  482.  * For example, Apache 1.4.2 would be '10402100', 2.5b7 would be '20500007'.
  483.  */
  484. #define APACHE_RELEASE 10326100
  485.  
  486. #define SERVER_PROTOCOL "HTTP/1.1"
  487. #ifndef SERVER_SUPPORT
  488. #define SERVER_SUPPORT "http://www.apache.org/"
  489. #endif
  490.  
  491. #define DECLINED -1        /* Module declines to handle */
  492. #define DONE -2            /* Module has served the response completely 
  493.                  *  - it's safe to die() with no more output
  494.                  */
  495. #define OK 0            /* Module has handled this stage. */
  496.  
  497.  
  498. /* ----------------------- HTTP Status Codes  ------------------------- */
  499.  
  500. /* The size of the static array in http_protocol.c for storing
  501.  * all of the potential response status-lines (a sparse table).
  502.  * A future version should dynamically generate the table at startup.
  503.  */
  504. #define RESPONSE_CODES 55
  505.  
  506. #define HTTP_CONTINUE                      100
  507. #define HTTP_SWITCHING_PROTOCOLS           101
  508. #define HTTP_PROCESSING                    102
  509. #define HTTP_OK                            200
  510. #define HTTP_CREATED                       201
  511. #define HTTP_ACCEPTED                      202
  512. #define HTTP_NON_AUTHORITATIVE             203
  513. #define HTTP_NO_CONTENT                    204
  514. #define HTTP_RESET_CONTENT                 205
  515. #define HTTP_PARTIAL_CONTENT               206
  516. #define HTTP_MULTI_STATUS                  207
  517. #define HTTP_MULTIPLE_CHOICES              300
  518. #define HTTP_MOVED_PERMANENTLY             301
  519. #define HTTP_MOVED_TEMPORARILY             302
  520. #define HTTP_SEE_OTHER                     303
  521. #define HTTP_NOT_MODIFIED                  304
  522. #define HTTP_USE_PROXY                     305
  523. #define HTTP_TEMPORARY_REDIRECT            307
  524. #define HTTP_BAD_REQUEST                   400
  525. #define HTTP_UNAUTHORIZED                  401
  526. #define HTTP_PAYMENT_REQUIRED              402
  527. #define HTTP_FORBIDDEN                     403
  528. #define HTTP_NOT_FOUND                     404
  529. #define HTTP_METHOD_NOT_ALLOWED            405
  530. #define HTTP_NOT_ACCEPTABLE                406
  531. #define HTTP_PROXY_AUTHENTICATION_REQUIRED 407
  532. #define HTTP_REQUEST_TIME_OUT              408
  533. #define HTTP_CONFLICT                      409
  534. #define HTTP_GONE                          410
  535. #define HTTP_LENGTH_REQUIRED               411
  536. #define HTTP_PRECONDITION_FAILED           412
  537. #define HTTP_REQUEST_ENTITY_TOO_LARGE      413
  538. #define HTTP_REQUEST_URI_TOO_LARGE         414
  539. #define HTTP_UNSUPPORTED_MEDIA_TYPE        415
  540. #define HTTP_RANGE_NOT_SATISFIABLE         416
  541. #define HTTP_EXPECTATION_FAILED            417
  542. #define HTTP_UNPROCESSABLE_ENTITY          422
  543. #define HTTP_LOCKED                        423
  544. #define HTTP_FAILED_DEPENDENCY             424
  545. #define HTTP_INTERNAL_SERVER_ERROR         500
  546. #define HTTP_NOT_IMPLEMENTED               501
  547. #define HTTP_BAD_GATEWAY                   502
  548. #define HTTP_SERVICE_UNAVAILABLE           503
  549. #define HTTP_GATEWAY_TIME_OUT              504
  550. #define HTTP_VERSION_NOT_SUPPORTED         505
  551. #define HTTP_VARIANT_ALSO_VARIES           506
  552. #define HTTP_INSUFFICIENT_STORAGE          507
  553. #define HTTP_NOT_EXTENDED                  510
  554.  
  555. #define DOCUMENT_FOLLOWS    HTTP_OK
  556. #define PARTIAL_CONTENT     HTTP_PARTIAL_CONTENT
  557. #define MULTIPLE_CHOICES    HTTP_MULTIPLE_CHOICES
  558. #define MOVED               HTTP_MOVED_PERMANENTLY
  559. #define REDIRECT            HTTP_MOVED_TEMPORARILY
  560. #define USE_LOCAL_COPY      HTTP_NOT_MODIFIED
  561. #define BAD_REQUEST         HTTP_BAD_REQUEST
  562. #define AUTH_REQUIRED       HTTP_UNAUTHORIZED
  563. #define FORBIDDEN           HTTP_FORBIDDEN
  564. #define NOT_FOUND           HTTP_NOT_FOUND
  565. #define METHOD_NOT_ALLOWED  HTTP_METHOD_NOT_ALLOWED
  566. #define NOT_ACCEPTABLE      HTTP_NOT_ACCEPTABLE
  567. #define LENGTH_REQUIRED     HTTP_LENGTH_REQUIRED
  568. #define PRECONDITION_FAILED HTTP_PRECONDITION_FAILED
  569. #define SERVER_ERROR        HTTP_INTERNAL_SERVER_ERROR
  570. #define NOT_IMPLEMENTED     HTTP_NOT_IMPLEMENTED
  571. #define BAD_GATEWAY         HTTP_BAD_GATEWAY
  572. #define VARIANT_ALSO_VARIES HTTP_VARIANT_ALSO_VARIES
  573.  
  574. #define ap_is_HTTP_INFO(x)         (((x) >= 100)&&((x) < 200))
  575. #define ap_is_HTTP_SUCCESS(x)      (((x) >= 200)&&((x) < 300))
  576. #define ap_is_HTTP_REDIRECT(x)     (((x) >= 300)&&((x) < 400))
  577. #define ap_is_HTTP_ERROR(x)        (((x) >= 400)&&((x) < 600))
  578. #define ap_is_HTTP_CLIENT_ERROR(x) (((x) >= 400)&&((x) < 500))
  579. #define ap_is_HTTP_SERVER_ERROR(x) (((x) >= 500)&&((x) < 600))
  580.  
  581. #define ap_status_drops_connection(x) \
  582.                                    (((x) == HTTP_BAD_REQUEST)           || \
  583.                                     ((x) == HTTP_REQUEST_TIME_OUT)      || \
  584.                                     ((x) == HTTP_LENGTH_REQUIRED)       || \
  585.                                     ((x) == HTTP_REQUEST_ENTITY_TOO_LARGE) || \
  586.                                     ((x) == HTTP_REQUEST_URI_TOO_LARGE) || \
  587.                                     ((x) == HTTP_INTERNAL_SERVER_ERROR) || \
  588.                                     ((x) == HTTP_SERVICE_UNAVAILABLE) || \
  589.                     ((x) == HTTP_NOT_IMPLEMENTED))
  590.  
  591. /* Methods recognized (but not necessarily handled) by the server.
  592.  * These constants are used in bit shifting masks of size int, so it is
  593.  * unsafe to have more methods than bits in an int.  HEAD == M_GET.
  594.  */
  595. #define M_GET        0
  596. #define M_PUT        1
  597. #define M_POST       2
  598. #define M_DELETE     3
  599. #define M_CONNECT    4
  600. #define M_OPTIONS    5
  601. #define M_TRACE      6
  602. #define M_PATCH      7
  603. #define M_PROPFIND   8
  604. #define M_PROPPATCH  9
  605. #define M_MKCOL     10
  606. #define M_COPY      11
  607. #define M_MOVE      12
  608. #define M_LOCK      13
  609. #define M_UNLOCK    14
  610. #define M_INVALID   15
  611.  
  612. #define METHODS     16
  613.  
  614. #define CGI_MAGIC_TYPE "application/x-httpd-cgi"
  615. #define INCLUDES_MAGIC_TYPE "text/x-server-parsed-html"
  616. #define INCLUDES_MAGIC_TYPE3 "text/x-server-parsed-html3"
  617. #ifdef CHARSET_EBCDIC
  618. #define ASCIITEXT_MAGIC_TYPE_PREFIX "text/x-ascii-" /* Text files whose content-type starts with this are passed thru unconverted */
  619. #endif /*CHARSET_EBCDIC*/
  620. #define MAP_FILE_MAGIC_TYPE "application/x-type-map"
  621. #define ASIS_MAGIC_TYPE "httpd/send-as-is"
  622. #define DIR_MAGIC_TYPE "httpd/unix-directory"
  623. #define STATUS_MAGIC_TYPE "application/x-httpd-status"
  624.  
  625. /*
  626.  * Define the HTML doctype strings centrally.
  627.  */
  628. #define DOCTYPE_HTML_2_0  "<!DOCTYPE HTML PUBLIC \"-//IETF//" \
  629.                           "DTD HTML 2.0//EN\">\n"
  630. #define DOCTYPE_HTML_3_2  "<!DOCTYPE HTML PUBLIC \"-//W3C//" \
  631.                           "DTD HTML 3.2 Final//EN\">\n"
  632. #define DOCTYPE_HTML_4_0S "<!DOCTYPE HTML PUBLIC \"-//W3C//" \
  633.                           "DTD HTML 4.0//EN\"\n" \
  634.                           "\"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
  635. #define DOCTYPE_HTML_4_0T "<!DOCTYPE HTML PUBLIC \"-//W3C//" \
  636.                           "DTD HTML 4.0 Transitional//EN\"\n" \
  637.                           "\"http://www.w3.org/TR/REC-html40/loose.dtd\">\n"
  638. #define DOCTYPE_HTML_4_0F "<!DOCTYPE HTML PUBLIC \"-//W3C//" \
  639.                           "DTD HTML 4.0 Frameset//EN\"\n" \
  640.                           "\"http://www.w3.org/TR/REC-html40/frameset.dtd\">\n"
  641.  
  642. /* Just in case your linefeed isn't the one the other end is expecting. */
  643. #ifndef CHARSET_EBCDIC
  644. #define LF 10
  645. #define CR 13
  646. #define CRLF "\015\012"
  647. #define OS_ASC(c) (c)
  648. #else /* CHARSET_EBCDIC */
  649. #include "ap_ebcdic.h"
  650. /* OSD_POSIX uses the EBCDIC charset. The transition ASCII->EBCDIC is done in
  651.  * the buff package (bread/bputs/bwrite), so everywhere else, we use
  652.  * "native EBCDIC" CR and NL characters. These are therefore defined as
  653.  * '\r' and '\n'.
  654.  * NB: this is not the whole truth - sometimes \015 and \012 are contained
  655.  * in literal (EBCDIC!) strings, so these are not converted but passed.
  656.  */
  657. #define CR '\r'
  658. #define LF '\n'
  659. #define CRLF "\r\n"
  660. #define OS_ASC(c) (os_toascii[c])
  661. #endif /* CHARSET_EBCDIC */
  662.  
  663. /* Possible values for request_rec.read_body (set by handling module):
  664.  *    REQUEST_NO_BODY          Send 413 error if message has any body
  665.  *    REQUEST_CHUNKED_ERROR    Send 411 error if body without Content-Length
  666.  *    REQUEST_CHUNKED_DECHUNK  If chunked, remove the chunks for me.
  667.  *    REQUEST_CHUNKED_PASS     Pass the chunks to me without removal.
  668.  */
  669. #define REQUEST_NO_BODY          0
  670. #define REQUEST_CHUNKED_ERROR    1
  671. #define REQUEST_CHUNKED_DECHUNK  2
  672. #define REQUEST_CHUNKED_PASS     3
  673.  
  674. /* Things which may vary per file-lookup WITHIN a request ---
  675.  * e.g., state of MIME config.  Basically, the name of an object, info
  676.  * about the object, and any other info we may ahve which may need to
  677.  * change as we go poking around looking for it (e.g., overridden by
  678.  * .htaccess files).
  679.  *
  680.  * Note how the default state of almost all these things is properly
  681.  * zero, so that allocating it with pcalloc does the right thing without
  682.  * a whole lot of hairy initialization... so long as we are willing to
  683.  * make the (fairly) portable assumption that the bit pattern of a NULL
  684.  * pointer is, in fact, zero.
  685.  */
  686.  
  687. /* This represents the result of calling htaccess; these are cached for
  688.  * each request.
  689.  */
  690. struct htaccess_result {
  691.     char *dir;            /* the directory to which this applies */
  692.     int override;        /* the overrides allowed for the .htaccess file */
  693.     void *htaccess;        /* the configuration directives */
  694. /* the next one, or NULL if no more; N.B. never change this */
  695.     const struct htaccess_result *next;
  696. };
  697.  
  698. typedef struct conn_rec conn_rec;
  699. typedef struct server_rec server_rec;
  700. typedef struct request_rec request_rec;
  701. typedef struct listen_rec listen_rec;
  702.  
  703. #include "util_uri.h"
  704.  
  705. enum proxyreqtype {
  706.     NOT_PROXY=0,
  707.     STD_PROXY,
  708.     PROXY_PASS
  709. };
  710.  
  711. struct request_rec {
  712.  
  713.     ap_pool *pool;
  714.     conn_rec *connection;
  715.     server_rec *server;
  716.  
  717.     request_rec *next;        /* If we wind up getting redirected,
  718.                  * pointer to the request we redirected to.
  719.                  */
  720.     request_rec *prev;        /* If this is an internal redirect,
  721.                  * pointer to where we redirected *from*.
  722.                  */
  723.  
  724.     request_rec *main;        /* If this is a sub_request (see request.h) 
  725.                  * pointer back to the main request.
  726.                  */
  727.  
  728.     /* Info about the request itself... we begin with stuff that only
  729.      * protocol.c should ever touch...
  730.      */
  731.  
  732.     char *the_request;        /* First line of request, so we can log it */
  733.     int assbackwards;        /* HTTP/0.9, "simple" request */
  734.     enum proxyreqtype proxyreq;/* A proxy request (calculated during
  735.                  * post_read_request or translate_name) */
  736.     int header_only;        /* HEAD request, as opposed to GET */
  737.     char *protocol;        /* Protocol, as given to us, or HTTP/0.9 */
  738.     int proto_num;        /* Number version of protocol; 1.1 = 1001 */
  739.     const char *hostname;    /* Host, as set by full URI or Host: */
  740.  
  741.     time_t request_time;    /* When the request started */
  742.  
  743.     const char *status_line;    /* Status line, if set by script */
  744.     int status;            /* In any case */
  745.  
  746.     /* Request method, two ways; also, protocol, etc..  Outside of protocol.c,
  747.      * look, but don't touch.
  748.      */
  749.  
  750.     const char *method;        /* GET, HEAD, POST, etc. */
  751.     int method_number;        /* M_GET, M_POST, etc. */
  752.  
  753.     /*
  754.     allowed is a bitvector of the allowed methods.
  755.  
  756.     A handler must ensure that the request method is one that
  757.     it is capable of handling.  Generally modules should DECLINE
  758.     any request methods they do not handle.  Prior to aborting the
  759.     handler like this the handler should set r->allowed to the list
  760.     of methods that it is willing to handle.  This bitvector is used
  761.     to construct the "Allow:" header required for OPTIONS requests,
  762.     and METHOD_NOT_ALLOWED and NOT_IMPLEMENTED status codes.
  763.  
  764.     Since the default_handler deals with OPTIONS, all modules can
  765.     usually decline to deal with OPTIONS.  TRACE is always allowed,
  766.     modules don't need to set it explicitly.
  767.  
  768.     Since the default_handler will always handle a GET, a
  769.     module which does *not* implement GET should probably return
  770.     METHOD_NOT_ALLOWED.  Unfortunately this means that a Script GET
  771.     handler can't be installed by mod_actions.
  772.     */
  773.     int allowed;        /* Allowed methods - for 405, OPTIONS, etc */
  774.  
  775.     int sent_bodyct;        /* byte count in stream is for body */
  776.     long bytes_sent;        /* body byte count, for easy access */
  777.     time_t mtime;        /* Time the resource was last modified */
  778.  
  779.     /* HTTP/1.1 connection-level features */
  780.  
  781.     int chunked;        /* sending chunked transfer-coding */
  782.     int byterange;        /* number of byte ranges */
  783.     char *boundary;        /* multipart/byteranges boundary */
  784.     const char *range;        /* The Range: header */
  785.     long clength;        /* The "real" content length */
  786.  
  787.     long remaining;        /* bytes left to read */
  788.     long read_length;        /* bytes that have been read */
  789.     int read_body;        /* how the request body should be read */
  790.     int read_chunked;        /* reading chunked transfer-coding */
  791.     unsigned expecting_100;    /* is client waiting for a 100 response? */
  792.  
  793.     /* MIME header environments, in and out.  Also, an array containing
  794.      * environment variables to be passed to subprocesses, so people can
  795.      * write modules to add to that environment.
  796.      *
  797.      * The difference between headers_out and err_headers_out is that the
  798.      * latter are printed even on error, and persist across internal redirects
  799.      * (so the headers printed for ErrorDocument handlers will have them).
  800.      *
  801.      * The 'notes' table is for notes from one module to another, with no
  802.      * other set purpose in mind...
  803.      */
  804.  
  805.     table *headers_in;
  806.     table *headers_out;
  807.     table *err_headers_out;
  808.     table *subprocess_env;
  809.     table *notes;
  810.  
  811.     /* content_type, handler, content_encoding, content_language, and all
  812.      * content_languages MUST be lowercased strings.  They may be pointers
  813.      * to static strings; they should not be modified in place.
  814.      */
  815.     const char *content_type;    /* Break these out --- we dispatch on 'em */
  816.     const char *handler;    /* What we *really* dispatch on           */
  817.  
  818.     const char *content_encoding;
  819.     const char *content_language;    /* for back-compat. only -- do not use */
  820.     array_header *content_languages;    /* array of (char*) */
  821.  
  822.     char *vlist_validator;      /* variant list validator (if negotiated) */
  823.  
  824.     int no_cache;
  825.     int no_local_copy;
  826.  
  827.     /* What object is being requested (either directly, or via include
  828.      * or content-negotiation mapping).
  829.      */
  830.  
  831.     char *unparsed_uri;        /* the uri without any parsing performed */
  832.     char *uri;            /* the path portion of the URI */
  833.     char *filename;        /* filename if found, otherwise NULL */
  834.     char *path_info;
  835.     char *args;            /* QUERY_ARGS, if any */
  836.     struct stat finfo;        /* ST_MODE set to zero if no such file */
  837.     uri_components parsed_uri;    /* components of uri, dismantled */
  838.  
  839.     /* Various other config info which may change with .htaccess files
  840.      * These are config vectors, with one void* pointer for each module
  841.      * (the thing pointed to being the module's business).
  842.      */
  843.  
  844.     void *per_dir_config;    /* Options set in config files, etc. */
  845.     void *request_config;    /* Notes on *this* request */
  846.  
  847. /*
  848.  * a linked list of the configuration directives in the .htaccess files
  849.  * accessed by this request.
  850.  * N.B. always add to the head of the list, _never_ to the end.
  851.  * that way, a sub request's list can (temporarily) point to a parent's list
  852.  */
  853.     const struct htaccess_result *htaccess;
  854.  
  855.     /* On systems with case insensitive file systems (Windows, OS/2, etc.), 
  856.      * r->filename is case canonicalized (folded to either lower or upper 
  857.      * case, depending on the specific system) to accomodate file access
  858.      * checking. case_preserved_filename is the same as r->filename 
  859.      * except case is preserved. There is at least one instance where Apache 
  860.      * needs access to the case preserved filename: Java class files published 
  861.      * with WebDAV need to preserve filename case to make the Java compiler 
  862.      * happy.
  863.      */
  864.     char *case_preserved_filename;
  865.  
  866. #ifdef CHARSET_EBCDIC
  867.     /* We don't want subrequests to modify our current conversion flags.
  868.      * These flags save the state of the conversion flags when subrequests
  869.      * are run.
  870.      */
  871.     struct {
  872.         unsigned conv_in:1;    /* convert ASCII->EBCDIC when read()ing? */
  873.         unsigned conv_out:1;   /* convert EBCDIC->ASCII when write()ing? */
  874.     } ebcdic;
  875. #endif
  876.  
  877. /* Things placed at the end of the record to avoid breaking binary
  878.  * compatibility.  It would be nice to remember to reorder the entire
  879.  * record to improve 64bit alignment the next time we need to break
  880.  * binary compatibility for some other reason.
  881.  */
  882.  
  883. #ifdef EAPI
  884.     ap_ctx *ctx;
  885. #endif /* EAPI */
  886. };
  887.  
  888.  
  889. /* Things which are per connection
  890.  */
  891.  
  892. struct conn_rec {
  893.  
  894.     ap_pool *pool;
  895.     server_rec *server;
  896.     server_rec *base_server;    /* Physical vhost this conn come in on */
  897.     void *vhost_lookup_data;    /* used by http_vhost.c */
  898.  
  899.     /* Information about the connection itself */
  900.  
  901.     int child_num;        /* The number of the child handling conn_rec */
  902.     BUFF *client;        /* Connection to the guy */
  903.  
  904.     /* Who is the client? */
  905.  
  906.     struct sockaddr_in local_addr;    /* local address */
  907.     struct sockaddr_in remote_addr;    /* remote address */
  908.     char *remote_ip;        /* Client's IP address */
  909.     char *remote_host;        /* Client's DNS name, if known.
  910.                  * NULL if DNS hasn't been checked,
  911.                  * "" if it has and no address was found.
  912.                  * N.B. Only access this though
  913.                  * get_remote_host() */
  914.     char *remote_logname;    /* Only ever set if doing rfc1413 lookups.
  915.                  * N.B. Only access this through
  916.                  * get_remote_logname() */
  917.     char *user;            /* If an authentication check was made,
  918.                  * this gets set to the user name.  We assume
  919.                  * that there's only one user per connection(!)
  920.                  */
  921.     char *ap_auth_type;        /* Ditto. */
  922.  
  923.     unsigned aborted:1;        /* Are we still talking? */
  924.     signed int keepalive:2;    /* Are we using HTTP Keep-Alive?
  925.                  * -1 fatal error, 0 undecided, 1 yes */
  926.     unsigned keptalive:1;    /* Did we use HTTP Keep-Alive? */
  927.     signed int double_reverse:2;/* have we done double-reverse DNS?
  928.                  * -1 yes/failure, 0 not yet, 1 yes/success */
  929.     int keepalives;        /* How many times have we used it? */
  930.     char *local_ip;        /* server IP address */
  931.     char *local_host;        /* used for ap_get_server_name when
  932.                  * UseCanonicalName is set to DNS
  933.                  * (ignores setting of HostnameLookups) */
  934. #ifdef EAPI
  935.     ap_ctx *ctx;
  936. #endif /* EAPI */
  937. };
  938.  
  939. /* Per-vhost config... */
  940.  
  941. /* The address 255.255.255.255, when used as a virtualhost address,
  942.  * will become the "default" server when the ip doesn't match other vhosts.
  943.  */
  944. #define DEFAULT_VHOST_ADDR 0xfffffffful
  945.  
  946. typedef struct server_addr_rec server_addr_rec;
  947. struct server_addr_rec {
  948.     server_addr_rec *next;
  949.     struct in_addr host_addr;    /* The bound address, for this server */
  950.     unsigned short host_port;    /* The bound port, for this server */
  951.     char *virthost;        /* The name given in <VirtualHost> */
  952. };
  953.  
  954. struct server_rec {
  955.  
  956.     server_rec *next;
  957.  
  958.     /* description of where the definition came from */
  959.     const char *defn_name;
  960.     unsigned defn_line_number;
  961.  
  962.     /* Full locations of server config info */
  963.  
  964.     char *srm_confname;
  965.     char *access_confname;
  966.  
  967.     /* Contact information */
  968.  
  969.     char *server_admin;
  970.     char *server_hostname;
  971.     unsigned short port;    /* for redirects, etc. */
  972.  
  973.     /* Log files --- note that transfer log is now in the modules... */
  974.  
  975.     char *error_fname;
  976.     FILE *error_log;
  977.     int loglevel;
  978.  
  979.     /* Module-specific configuration for server, and defaults... */
  980.  
  981.     int is_virtual;        /* true if this is the virtual server */
  982.     void *module_config;    /* Config vector containing pointers to
  983.                  * modules' per-server config structures.
  984.                  */
  985.     void *lookup_defaults;    /* MIME type info, etc., before we start
  986.                  * checking per-directory info.
  987.                  */
  988.     /* Transaction handling */
  989.  
  990.     server_addr_rec *addrs;
  991.     int timeout;        /* Timeout, in seconds, before we give up */
  992.     int keep_alive_timeout;    /* Seconds we'll wait for another request */
  993.     int keep_alive_max;        /* Maximum requests per connection */
  994.     int keep_alive;        /* Use persistent connections? */
  995.     int send_buffer_size;    /* size of TCP send buffer (in bytes) */
  996.  
  997.     char *path;            /* Pathname for ServerPath */
  998.     int pathlen;        /* Length of path */
  999.  
  1000.     array_header *names;    /* Normal names for ServerAlias servers */
  1001.     array_header *wild_names;    /* Wildcarded names for ServerAlias servers */
  1002.  
  1003.     uid_t server_uid;        /* effective user id when calling exec wrapper */
  1004.     gid_t server_gid;        /* effective group id when calling exec wrapper */
  1005.  
  1006.     int limit_req_line;      /* limit on size of the HTTP request line    */
  1007.     int limit_req_fieldsize; /* limit on size of any request header field */
  1008.     int limit_req_fields;    /* limit on number of request header fields  */
  1009.  
  1010. #ifdef EAPI
  1011.     ap_ctx *ctx;
  1012. #endif /* EAPI */
  1013. };
  1014.  
  1015. /* These are more like real hosts than virtual hosts */
  1016. struct listen_rec {
  1017.     listen_rec *next;
  1018.     struct sockaddr_in local_addr;    /* local IP address and port */
  1019.     int fd;
  1020.     int used;            /* Only used during restart */        
  1021. /* more stuff here, like which protocol is bound to the port */
  1022. };
  1023.  
  1024. /* Prototypes for utilities... util.c.
  1025.  */
  1026.  
  1027. extern void ap_util_init(void);
  1028.  
  1029. /* Time */
  1030. extern API_VAR_EXPORT const char ap_month_snames[12][4];
  1031. extern API_VAR_EXPORT const char ap_day_snames[7][4];
  1032.  
  1033. API_EXPORT(struct tm *) ap_get_gmtoff(int *tz);
  1034. API_EXPORT(char *) ap_get_time(void);
  1035. API_EXPORT(char *) ap_field_noparam(pool *p, const char *intype);
  1036. API_EXPORT(char *) ap_ht_time(pool *p, time_t t, const char *fmt, int gmt);
  1037. API_EXPORT(char *) ap_gm_timestr_822(pool *p, time_t t);
  1038.  
  1039. /* String handling. The *_nc variants allow you to use non-const char **s as
  1040.    arguments (unfortunately C won't automatically convert a char ** to a const
  1041.    char **) */
  1042.  
  1043. API_EXPORT(char *) ap_getword(pool *p, const char **line, char stop);
  1044. API_EXPORT(char *) ap_getword_nc(pool *p, char **line, char stop);
  1045. API_EXPORT(char *) ap_getword_white(pool *p, const char **line);
  1046. API_EXPORT(char *) ap_getword_white_nc(pool *p, char **line);
  1047. API_EXPORT(char *) ap_getword_nulls(pool *p, const char **line, char stop);
  1048. API_EXPORT(char *) ap_getword_nulls_nc(pool *p, char **line, char stop);
  1049. API_EXPORT(char *) ap_getword_conf(pool *p, const char **line);
  1050. API_EXPORT(char *) ap_getword_conf_nc(pool *p, char **line);
  1051.  
  1052. API_EXPORT(const char *) ap_size_list_item(const char **field, int *len);
  1053. API_EXPORT(char *) ap_get_list_item(pool *p, const char **field);
  1054. API_EXPORT(int) ap_find_list_item(pool *p, const char *line, const char *tok);
  1055.  
  1056. API_EXPORT(char *) ap_get_token(pool *p, const char **accept_line, int accept_white);
  1057. API_EXPORT(int) ap_find_token(pool *p, const char *line, const char *tok);
  1058. API_EXPORT(int) ap_find_last_token(pool *p, const char *line, const char *tok);
  1059.  
  1060. API_EXPORT(int) ap_is_url(const char *u);
  1061. API_EXPORT(int) ap_unescape_url(char *url);
  1062. API_EXPORT(void) ap_no2slash(char *name);
  1063. API_EXPORT(void) ap_getparents(char *name);
  1064. API_EXPORT(char *) ap_escape_path_segment(pool *p, const char *s);
  1065. API_EXPORT(char *) ap_os_escape_path(pool *p, const char *path, int partial);
  1066. #define ap_escape_uri(ppool,path) ap_os_escape_path(ppool,path,1)
  1067. API_EXPORT(char *) ap_escape_html(pool *p, const char *s);
  1068. API_EXPORT(char *) ap_construct_server(pool *p, const char *hostname,
  1069.                     unsigned port, const request_rec *r);
  1070. API_EXPORT(char *) ap_escape_logitem(pool *p, const char *str);
  1071. API_EXPORT(char *) ap_escape_shell_cmd(pool *p, const char *s);
  1072.  
  1073. API_EXPORT(int) ap_count_dirs(const char *path);
  1074. API_EXPORT(char *) ap_make_dirstr_prefix(char *d, const char *s, int n);
  1075. API_EXPORT(char *) ap_make_dirstr_parent(pool *p, const char *s);
  1076. /* deprecated.  The previous two routines are preferred. */
  1077. API_EXPORT(char *) ap_make_dirstr(pool *a, const char *s, int n);
  1078. API_EXPORT(char *) ap_make_full_path(pool *a, const char *dir, const char *f);
  1079.  
  1080. API_EXPORT(int) ap_is_matchexp(const char *str);
  1081. API_EXPORT(int) ap_strcmp_match(const char *str, const char *exp);
  1082. API_EXPORT(int) ap_strcasecmp_match(const char *str, const char *exp);
  1083. API_EXPORT(char *) ap_stripprefix(const char *bigstring, const char *prefix);
  1084. API_EXPORT(char *) ap_strcasestr(const char *s1, const char *s2);
  1085. API_EXPORT(char *) ap_pbase64decode(pool *p, const char *bufcoded);
  1086. API_EXPORT(char *) ap_pbase64encode(pool *p, char *string); 
  1087. API_EXPORT(char *) ap_uudecode(pool *p, const char *bufcoded);
  1088. API_EXPORT(char *) ap_uuencode(pool *p, char *string); 
  1089.  
  1090. #if defined(OS2) || defined(WIN32)
  1091. API_EXPORT(char *) ap_double_quotes(pool *p, const char *str);
  1092. API_EXPORT(char *) ap_caret_escape_args(pool *p, const char *str);
  1093. #endif
  1094.  
  1095. #ifdef OS2
  1096. void os2pathname(char *path);
  1097. #endif
  1098.  
  1099. API_EXPORT(int)    ap_regexec(const regex_t *preg, const char *string,
  1100.                               size_t nmatch, regmatch_t pmatch[], int eflags);
  1101. API_EXPORT(size_t) ap_regerror(int errcode, const regex_t *preg, 
  1102.                                char *errbuf, size_t errbuf_size);
  1103. API_EXPORT(char *) ap_pregsub(pool *p, const char *input, const char *source,
  1104.                               size_t nmatch, regmatch_t pmatch[]);
  1105.  
  1106. API_EXPORT(void) ap_content_type_tolower(char *);
  1107. API_EXPORT(void) ap_str_tolower(char *);
  1108. API_EXPORT(int) ap_ind(const char *, char);    /* Sigh... */
  1109. API_EXPORT(int) ap_rind(const char *, char);
  1110.  
  1111. API_EXPORT(char *) ap_escape_quotes (pool *p, const char *instring);
  1112. API_EXPORT(void) ap_remove_spaces(char *dest, char *src);
  1113.  
  1114. /* Common structure for reading of config files / passwd files etc. */
  1115. typedef struct {
  1116.     int (*getch) (void *param);    /* a getc()-like function */
  1117.     void *(*getstr) (void *buf, size_t bufsiz, void *param); /* a fgets()-like function */
  1118.     int (*close) (void *param);    /* a close hander function */
  1119.     void *param;        /* the argument passed to getch/getstr/close */
  1120.     const char *name;        /* the filename / description */
  1121.     unsigned line_number;    /* current line number, starting at 1 */
  1122. } configfile_t;
  1123.  
  1124. /* Open a configfile_t as FILE, return open configfile_t struct pointer */
  1125. API_EXPORT(configfile_t *) ap_pcfg_openfile(pool *p, const char *name);
  1126.  
  1127. /* Allocate a configfile_t handle with user defined functions and params */
  1128. API_EXPORT(configfile_t *) ap_pcfg_open_custom(pool *p, const char *descr,
  1129.     void *param,
  1130.     int(*getc_func)(void*),
  1131.     void *(*gets_func) (void *buf, size_t bufsiz, void *param),
  1132.     int(*close_func)(void *param));
  1133.  
  1134. /* Read one line from open configfile_t, strip LF, increase line number */
  1135. API_EXPORT(int) ap_cfg_getline(char *buf, size_t bufsize, configfile_t *cfp);
  1136.  
  1137. /* Read one char from open configfile_t, increase line number upon LF */
  1138. API_EXPORT(int) ap_cfg_getc(configfile_t *cfp);
  1139.  
  1140. /* Detach from open configfile_t, calling the close handler */
  1141. API_EXPORT(int) ap_cfg_closefile(configfile_t *cfp);
  1142.  
  1143. #ifdef NEED_STRERROR
  1144. char *strerror(int err);
  1145. #endif
  1146.  
  1147. /* Misc system hackery */
  1148.  
  1149. API_EXPORT(uid_t) ap_uname2id(const char *name);
  1150. API_EXPORT(gid_t) ap_gname2id(const char *name);
  1151. API_EXPORT(int) ap_is_directory(const char *name);
  1152. API_EXPORT(int) ap_is_rdirectory(const char *name);
  1153. API_EXPORT(int) ap_can_exec(const struct stat *);
  1154. API_EXPORT(void) ap_chdir_file(const char *file);
  1155.  
  1156. #ifndef HAVE_CANONICAL_FILENAME
  1157. /*
  1158.  *  We can't define these in os.h because of dependence on pool pointer.
  1159.  */
  1160. #define ap_os_canonical_filename(p,f)  (f)
  1161. #define ap_os_case_canonical_filename(p,f)  (f)
  1162. #define ap_os_systemcase_filename(p,f)  (f)
  1163. #else
  1164. API_EXPORT(char *) ap_os_canonical_filename(pool *p, const char *file);
  1165. #ifdef WIN32
  1166. API_EXPORT(char *) ap_os_case_canonical_filename(pool *pPool, const char *szFile);
  1167. API_EXPORT(char *) ap_os_systemcase_filename(pool *pPool, const char *szFile);
  1168. #elif defined(OS2)
  1169. API_EXPORT(char *) ap_os_case_canonical_filename(pool *pPool, const char *szFile);
  1170. API_EXPORT(char *) ap_os_systemcase_filename(pool *pPool, const char *szFile);
  1171. #elif defined(NETWARE)
  1172. API_EXPORT(char *) ap_os_case_canonical_filename(pool *pPool, const char *szFile);
  1173. #define ap_os_systemcase_filename(p,f) ap_os_case_canonical_filename(p,f)
  1174. #else
  1175. #define ap_os_case_canonical_filename(p,f) ap_os_canonical_filename(p,f)
  1176. #define ap_os_systemcase_filename(p,f) ap_os_canonical_filename(p,f)
  1177. #endif
  1178. #endif
  1179.  
  1180. #ifdef CHARSET_EBCDIC
  1181. API_EXPORT(int)    ap_checkconv(struct request_rec *r);    /* for downloads */
  1182. API_EXPORT(int)    ap_checkconv_in(struct request_rec *r); /* for uploads */
  1183. #endif /*#ifdef CHARSET_EBCDIC*/
  1184.  
  1185. API_EXPORT(char *) ap_get_local_host(pool *);
  1186. API_EXPORT(unsigned long) ap_get_virthost_addr(char *hostname, unsigned short *port);
  1187.  
  1188. extern API_VAR_EXPORT time_t ap_restart_time;
  1189.  
  1190. /*
  1191.  * Apache tries to keep all of its long term filehandles (such as log files,
  1192.  * and sockets) above this number.  This is to workaround problems in many
  1193.  * third party libraries that are compiled with a small FD_SETSIZE.  There
  1194.  * should be no reason to lower this, because it's only advisory.  If a file
  1195.  * can't be allocated above this number then it will remain in the "slack"
  1196.  * area.
  1197.  *
  1198.  * Only the low slack line is used by default.  If HIGH_SLACK_LINE is defined
  1199.  * then an attempt is also made to keep all non-FILE * files above the high
  1200.  * slack line.  This is to work around a Solaris C library limitation, where it
  1201.  * uses an unsigned char to store the file descriptor.
  1202.  */
  1203. #ifndef LOW_SLACK_LINE
  1204. #define LOW_SLACK_LINE    15
  1205. #endif
  1206. /* #define HIGH_SLACK_LINE      255 */
  1207.  
  1208. /*
  1209.  * The ap_slack() function takes a fd, and tries to move it above the indicated
  1210.  * line.  It returns an fd which may or may not have moved above the line, and
  1211.  * never fails.  If the high line was requested and it fails it will also try
  1212.  * the low line.
  1213.  */
  1214. #ifdef NO_SLACK
  1215. #define ap_slack(fd,line)   (fd)
  1216. #else
  1217. int ap_slack(int fd, int line);
  1218. #define AP_SLACK_LOW    1
  1219. #define AP_SLACK_HIGH    2
  1220. #endif
  1221.  
  1222. API_EXPORT(char *) ap_escape_quotes(pool *p, const char *instr);
  1223.  
  1224. /*
  1225.  * Redefine assert() to something more useful for an Apache...
  1226.  */
  1227. API_EXPORT(void) ap_log_assert(const char *szExp, const char *szFile, int nLine)
  1228.                 __attribute__((noreturn));
  1229. #define ap_assert(exp) ((exp) ? (void)0 : ap_log_assert(#exp,__FILE__,__LINE__))
  1230.  
  1231. /* The optimized timeout code only works if we're not MULTITHREAD and we're
  1232.  * also not using a scoreboard file
  1233.  */
  1234. #if !defined (MULTITHREAD) && \
  1235.     (defined (USE_MMAP_SCOREBOARD) || defined (USE_SHMGET_SCOREBOARD))
  1236. #define OPTIMIZE_TIMEOUTS
  1237. #endif
  1238.  
  1239. /* A set of flags which indicate places where the server should raise(SIGSTOP).
  1240.  * This is useful for debugging, because you can then attach to that process
  1241.  * with gdb and continue.  This is important in cases where one_process
  1242.  * debugging isn't possible.
  1243.  */
  1244. #define SIGSTOP_DETACH            1
  1245. #define SIGSTOP_MAKE_CHILD        2
  1246. #define SIGSTOP_SPAWN_CHILD        4
  1247. #define SIGSTOP_PIPED_LOG_SPAWN        8
  1248. #define SIGSTOP_CGI_CHILD        16
  1249.  
  1250. #ifdef DEBUG_SIGSTOP
  1251. extern int raise_sigstop_flags;
  1252. #define RAISE_SIGSTOP(x)    do { \
  1253.     if (raise_sigstop_flags & SIGSTOP_##x) raise(SIGSTOP);\
  1254.     } while (0)
  1255. #else
  1256. #define RAISE_SIGSTOP(x)
  1257. #endif
  1258.  
  1259. API_EXPORT(extern const char *) ap_psignature(const char *prefix, request_rec *r);
  1260.  
  1261. /* strtoul does not exist on sunos4. */
  1262. #ifdef strtoul
  1263. #undef strtoul
  1264. #endif
  1265. #define strtoul strtoul_is_not_a_portable_function_use_strtol_instead
  1266.  
  1267. #ifdef __cplusplus
  1268. }
  1269. #endif
  1270.  
  1271. #endif    /* !APACHE_HTTPD_H */
  1272.